const router = require('koa-router')()
const { add } = require('../mysql/index.js')
const path = require('path');
const fse = require('fs-extra');
const multiparty = require('multiparty');  // 解析 FormData

router.post('/videoadd  ', async (ctx, next) => {
  try {
    console.log(ctx.request.body.data,'数据');
    ctx.body={
      msg:'上传成功'
    }
  } catch (error) {
    console.log(error,'错误');
    ctx.body = {
      code: '2',
      data: error,
      msg: '服务器异常'
    }
  }
  next()
})

router.post('/picadd', async (ctx, next) => {
  try {
    console.log(ctx.request.body.file);
    ctx.body={
      msg:'上传成功'
    }
  } catch (error) {
    ctx.body = {
      code: '2',
      data: error,
      msg: '服务器异常'
    }
  }
  next()
})

router.post('/textadd', async (ctx, next) => {
  try {
    console.log(ctx.request.body.file);
    ctx.body={
      msg:'上传成功'
    }
  } catch (error) {
    ctx.body = {
      code: '2',
      data: error,
      msg: '服务器异常'
    }
  }
  next()
})

router.post('/titleadd', async (ctx, next) => {
  try {
    console.log(ctx.request.body.file);
    ctx.body={
      msg:'上传成功'
    }
  } catch (error) {
    ctx.body = {
      code: '2',
      data: error,
      msg: '服务器异常'
    }
  }
  next()
})

module.exports = router
